1. Field of the Invention
The invention relates to a method for programming data, and more particularly, to a method for programming data in a rewritable non-volatile memory module, and a memory controller and a memory storage device using the same.
2. Description of Related Art
Rewritable non-volatile memory is one of the most adaptable memories for portable electronic products such as digital camera, cell phone and MP3 player due to its data non-volatility, low power consumption, small volume and non-mechanical structure. A solid state drive is a storage device adopting flash memory as storage medium.
Generally, a flash memory module of a flash memory storage device is divided into a plurality of physical blocks, in which the physical blocks are further divided into a plurality of physical pages. In the flash memory, the physical block is an erase unit and the physical page is a writing unit. Since only unidirectional programming (i.e., by programming the value of the memory cell from 1 to 0) may be performed to programming memory cells of the flash memory, a direct writing to a programmed physical page (i.e., page that is stored with old data) may not be performed before such physical page has been erased for re-programming. In particular, since the physical block is used as a unit for erasing the flash memory, if an erasing operation is performed to the physical page stored with old data, the physical block that contains the physical page is erased entirely. Therefore, the physical blocks of the flash memory module are divided into a data area and a spare area, in which the physical blocks in the data area are physical blocks already stored with data and the physical blocks in the spare area are physical block not being used. In which, if the host system intends to write data into the flash memory storage device, the physical block in the spare area may be accessed by the control circuit of the flash memory storage device for writing data, and the physical blocks being accessed are related to the data area. In addition, after an erasing operation to the physical blocks of the data area is performed, the physical blocks being erased are related to the spare area.
Based on above architecture in regard to the applications of using flash memory as storage device to ensure a secure data-writing, in order to align the data with the physical pages, each time a write command from the host system is processed, it is necessary to have old valid data read from the flash memory, so as to fill the data bring written. Once the data is programmed into the flash memory, a message indicating whether the writing operation is completed is sent back to the host system. That is to say, in order to ensure a secure data-writing operation, a programming result needs to be reply to the host system so as to control writing statuses of the data. Obviously, in the case if the host system intends to establish a plurality of write commands sequentially, it is necessary to have above-said processes performed for each of the writing commands. Since each of the writing commands a specific amount of program time, it is quite difficult to increase writing speed if under using of the secure data writing.